import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.tree.*;
import javax.swing.border.*;


public class TermExam extends JInternalFrame implements InterInterface,InternalFrameListener
{
	public static int a1 = 0;
	public static int a2 = 0;
	public static int a3 = 0;
	public static int a4 = 0;
	public static int a5 = 0;
	public static int a6 = 0;
	public static int a7 = 0;
	public static int a8 = 0;
	public static int a9 = 0;
	
	public TermExam()
	{
		super("University Lab Examination",false,true,false,false);
		this.setBounds(30,10,500,400);
		setVisible(true);
		
		try
		{
			UIManager.setLookAndFeel(looks[1].getClassName());
			SwingUtilities.updateComponentTreeUI(this);
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
		
		Container c = getContentPane();
		c.setLayout(null);
		lab1.setText("\tUniversity Lab Examination");
		lab1.setFont(new Font("Verdana",Font.BOLD,16));
		lab1.setEditable(false);
		lab1.setForeground(Color.black);
		lab1.setBackground(Color.gray);
		lab1.setBounds(0,0,500,30);
		c.add(lab1);
		JPanel pan = new JPanel();
		pan.setBorder(new TitledBorder(new EtchedBorder(),"Question & Time"));
		pan.add(bt1);
		//pan.add(bt2);
		pan.add(bt3);
		//pan.add(bt4);
		
		pan.setBounds(1,40,490,90);
		c.add(pan);
		
		JPanel pan1 = new JPanel();
		pan1.setBorder(new TitledBorder(new EtchedBorder(),"Result"));
		pan1.add(bt5);
		pan1.add(bt6);
		bt5.setEnabled(false);
		bt6.setEnabled(false);
		
		pan1.setBounds(1,140,490,90);
		c.add(pan1);
		
		JPanel pan2 = new JPanel();
		pan2.setBorder(new TitledBorder(new EtchedBorder(),"Service"));
		pan2.add(bt7);
		pan2.add(bt8);
		//pan2.add(bt9);
		
		pan2.setBounds(1,240,490,90);
		c.add(pan2);
		
		
		bt1.addActionListener(new ActionListener()
		{
		public void actionPerformed(ActionEvent e)
		{
			QuesSetting();
		}
		}
		);
		//bt2.addActionListener(new ActionListener()
		//{
		//public void actionPerformed(ActionEvent e)
		//{
		//	QuesToSend();
		//}
		//}
		//);	
		bt3.addActionListener(new ActionListener()
		{
		public void actionPerformed(ActionEvent e)
		{
			TimeSetting();
		}
		}
		);	
		
		bt5.addActionListener(new ActionListener()
		{
		public void actionPerformed(ActionEvent e)
		{
			ResultAnalysis();
		}
		}
		);	
		bt6.addActionListener(new ActionListener()
		{
		public void actionPerformed(ActionEvent e)
		{
			ResultPublish();
		}
		}
		);	
		bt7.addActionListener(new ActionListener()
		{
		public void actionPerformed(ActionEvent e)
		{
			StartExam();
		}
		}
		);	
		bt8.addActionListener(new ActionListener()
		{
		public void actionPerformed(ActionEvent e)
		{
			ViewLog();
		}
		}
		);	
				
	}

		
		
		
		protected void QuesSetting()
		{
			//System.out.println("Rabbi1");
			Qus_Sett qs = null;//new Qus_Sett();
			qs = new Qus_Sett();
			if(a1 == 0)
			{
			qs.Qus_Sett1();
			desktop.add(qs);
			a1 = 1;
			
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
			
			else{
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
		}
		
		protected void TimeSetting()
		{
			System.out.println("Rabbi3");
			Time_Sett qs= new Time_Sett();
			if(a2 == 0)
			{
			qs.Time_Sett1();
			desktop.add(qs);
			a2 = 1;
			
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
			
			else{
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
		}
		
		protected void ResultAnalysis()
		{
			System.out.println("Rabbi5");
			Res_Analy qs= new Res_Analy();
			if(a2 == 0)
			{
			qs.Res_Analy1();
			desktop.add(qs);
			a2 = 1;
			
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
			
			else{
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
		}
		protected void ResultPublish()
		{
			System.out.println("Rabbi6");
			Res_Pub qs= new Res_Pub();
			if(a2 == 0)
			{
			qs.Res_Pub1();
			desktop.add(qs);
			a2 = 1;
			
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
			
			else{
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
		}
		protected void StartExam()
		{
			System.out.println("Rabbi7");
			Start_Ex qs= new Start_Ex();
			if(a2 == 0)
			{
			qs.Start_Ex1();
			desktop.add(qs);
			a2 = 1;
			
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
			
			else{
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
		}
		protected void ViewLog()
		{
			System.out.println("Rabbi8");
			View_Log qs= new View_Log();
			if(a2 == 0)
			{
			qs.View_Log1();
			desktop.add(qs);
			a2 = 1;
			
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
			
			else{
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
		}
		protected void Help_m()
		{
			System.out.println("Rabbi9");
			Help qs= new Help();
			if(a2 == 0)
			{
			qs.Help1();
			desktop.add(qs);
			a2 = 1;
			
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
			
			else{
			try{
				qs.addInternalFrameListener(this);
				qs.setSelected(true);}
				catch(java.beans.PropertyVetoException p){};
			}
		}	
		


 public void internalFrameClosing(InternalFrameEvent e) 
 {
  	a1 = 0;
  	a2 = 0;
  	a3 = 0;
  	a4 = 0;
  	a5 = 0;
  	a6 = 0;
  	a7 = 0;
  	a8 = 0;
  	a9 = 0;
 }
 public void internalFrameClosed(InternalFrameEvent e) 
 {
   	a1 = 0;
   	a2 = 0;
   	a3 = 0;
   	a4 = 0;
   	a5 = 0;
   	a6 = 0;
   	a7 = 0;
   	a8 = 0;
   	a9 = 0;
        System.out.println("closed");
 }
 public void internalFrameOpened(InternalFrameEvent e) 
 {
 }
 public void internalFrameIconified(InternalFrameEvent e) 
 {
 }
 public void internalFrameDeiconified(InternalFrameEvent e) 
 {
 }
 public void internalFrameActivated(InternalFrameEvent e) 
 {
 }
 public void internalFrameDeactivated(InternalFrameEvent e) 
 {
 }	
}
